//
$(function(){
	
	//顶部菜单控制
	$dpmenu=$(".dp_m .cnt .topbar .navi div");
	//
	$dpmenu.click(function(){
		$dpmenu_n="naover"+($dpmenu.index($(this)[0])+1);
		for ( var i = 5; i > 0; i-- ) {
			$dpxuanze = ".nitem"+ i;
			$dplei = "naover" + i;
    		$($dpxuanze).removeClass($dplei);
			} 
		
		$(this).addClass($dpmenu_n);
		
		});
		
		
	//左侧菜单控制-一级菜单控制
	 $m_dt =$(".dp_m .cnt .mbody .left dt");
	 $m_dd =$(".dp_m .cnt .mbody .left dd");
	 $m_dt.click(function(){
		 //$m_dt.index($(this)[0])
		 $m_dt.removeClass("dtclick");
		 $(this).addClass("dtclick");
		 $(".dp_m .cnt .mbody .left dd").hide();
		 $(this).parent("dl").children("dd").show();
		 });
	 
	 //左侧菜单控制-二级菜单控制
	  $m_dd.hover(function(){
		 $(this).addClass("ddover").siblings().removeClass("ddover");	 
		 },
		 function(){
		 $(this).removeClass("ddover");	 
		 }
		 ); 
	  $m_dd.click(function(){
		 $(this).addClass("ddclick").siblings().removeClass("ddclick");
		 });
		 
	 //首页常见问题切换
	$i_sort = $(".dp_m .cnt .mbody .mright .cnt_sort");
	$i_sort.click(function(){
		
		$(this).toggleClass("cnt_sort1");
		
		});
		//
	$zf_sort = $(".dp_m .cnt .mbody .mleft .mbar2 .msel");
	$zf_sort.click(function(){
		
		});
		
		//首页轮播
		$("#mdp_slide1").Slide({
		effect : "scroolX",
		autoPlay:true,
		speed : "fast",
		timer : 3000,
		defIndex : 0,
		claCon:"mdp-jqsl-cnt",
		claNav:"mpagsel",
		steps:1
		});
		
		//视频轮播
		$("#mdp_slide2").Slide({
			effect : "scroolLoop",
			autoPlay:true,
			speed : "normal",
			timer : 3000,
			defIndex : 0,
			claCon:"vjqsl_cnt",
			claNav:"vjqsl_nav",
			steps:1
		});	
		
			//关闭评论
			$("#inpclose").click(function(){
				$(this).parent("#zhuanbo").hide();
				$(".pl_list_box").addClass("pl_list_box1");
				$(".pl_list_box .pl_labcnt").addClass("pl_labcnt1");
			});
		//战法评论列表：
		$slab = $(".pl_list_box .pl_labnav .slab")
		$slabcnt = $(".pl_list_box .pl_labcnt .box") 
		$slabcnt.eq(0).show();
		$slab.click(function(){
			$(this).addClass("slabover").siblings().removeClass("slabover");
			$slabcnt.hide().eq($slab.index($(this)[0])).show();
			});
})

//评分jq插件
jQuery.fn.rater	= function(options) {
		
	// 默认参数
	var settings = {
		enabled	: true,
		url		: '',
		method	: 'post',
		min		: 1,
		max		: 3,
		step	: 1,
		value	: null,
		after_click	: null,
		before_ajax	: null,
		after_ajax	: null,
		title_format	: null,
		image	: 'images/star.gif',
		width	: 16,
		height	: 16
	}; 
	
	// 自定义参数
	if(options) {  
		jQuery.extend(settings, options); 
	}
	
	// 主容器
	var content	= jQuery('<ul class="rater-star"></ul>');
	content.css('background-image' , 'url(' + settings.image + ')');
	content.css('height' , settings.height);
	content.css('width' , (settings.width*settings.step) * (settings.max-settings.min+settings.step)/settings.step);
	
	// 当前选中的
	var item	= jQuery('<li class="rater-star-item-current"></li>');
	item.css('background-image' , 'url(' + settings.image + ')');
	item.css('height' , settings.height);
	item.css('width' , 0);
	item.css('z-index' , settings.max / settings.step + 1);
	if (settings.value) {
		item.css('width' , ((settings.value-settings.min)/settings.step+1)*settings.step*settings.width);
	}
	
	content.append(item);
	
	// 星星
	for (var value=settings.min ; value<=settings.max ; value+=settings.step) {
		item	= jQuery('<li class="rater-star-item"></li>');
		
		if (typeof settings.title_format == 'function') {
			item.attr('title' , settings.title_format(value));
		}
		else {
			item.attr('title' , value);
		}
		item.css('height' , settings.height);
		item.css('width' , (value-settings.min+settings.step)*settings.width);
		item.css('z-index' , (settings.max - value) / settings.step + 1);
		item.css('background-image' , 'url(' + settings.image + ')');
		
		if (!settings.enabled) {	// 若是不能更改，则隐藏
			item.hide();
		}
		
		content.append(item);
	}
	
	content.mouseover(function(){
		if (settings.enabled) {
			jQuery(this).find('.rater-star-item-current').hide();
		}
	}).mouseout(function(){
			jQuery(this).find('.rater-star-item-current').show();
	})
	
	// 添加鼠标悬停/点击事件
	content.find('.rater-star-item').mouseover(function() {
		jQuery(this).attr('class' , 'rater-star-item-hover');
	}).mouseout(function() {
		jQuery(this).attr('class' , 'rater-star-item');
	}).click(function() {
		jQuery(this).prevAll('.rater-star-item-current').css('width' , jQuery(this).width());
		
		var star_count		= (settings.max - settings.min) + settings.step;
		var current_number	= jQuery(this).prevAll('.rater-star-item').size()+1;
		var current_value	= settings.min + (current_number - 1) * settings.step;
		var data	= {
			value	: current_value,
			number	: current_number,
			count	: star_count,
			min		: settings.min,
			max		: settings.max
		}
		
		// 处理回调事件
		if (typeof settings.after_click == 'function') {
			settings.after_click(data);
		}
		
		// 处理ajax调用
		if (settings.url) {
			
			jQuery.ajax({
				data		: data,
				type		: settings.method,
				url			: settings.url,
				beforeSend	: function() {
					if (typeof settings.before_ajax == 'function') {
						settings.before_ajax(data);
					}
				},
				success		: function(ret) {
					if (typeof settings.after_ajax == 'function') {
						data.ajax	= ret;
						settings.after_ajax(data);
					}
				}
			});
			
		}
	})
	
	jQuery(this).html(content);
	
}

